package com.xmcc.controller;

import com.xmcc.common.ResultJson;
import com.xmcc.dto.SysDeptDto;
import com.xmcc.pojo.SysRole;
import com.xmcc.service.SysDeptService;
import com.xmcc.service.SysTreeService;
import com.xmcc.utill.AclHelper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("sys/dept")
public class SysDeptController {
    @Autowired
    private SysDeptService sysDeptService;
    @Autowired
    private SysTreeService sysTreeService;
    @AclHelper(value="增加部门",module_id = 16)
    @RequestMapping("insert.json")
    @ResponseBody
    public ResultJson insert(SysDeptDto sysDeptDto){
        sysDeptService.insert(sysDeptDto);
        return ResultJson.success("插入成功");
    }
    @RequestMapping("fullTree.json")
    @ResponseBody
    public ResultJson fullTree(){
        return ResultJson.success(sysTreeService.sysDeptTree());
    }

    @AclHelper(value="修改部门",module_id = 16)
    @RequestMapping("update.json")
    @ResponseBody
    public ResultJson update(SysDeptDto sysDeptDto){
        sysDeptService.update(sysDeptDto);
        return ResultJson.success();
    }

    @RequestMapping("dept.page")
    public String deptPage(){
        return "dept";
    }

    @RequestMapping("delete.json")
    @ResponseBody
    public ResultJson deleteDeptId(Integer id){
        return sysDeptService.deleteDeptId(id);
    }
}
